package configuration;
import java.util.concurrent.*;
public class ModuleEntry {
	private ConcurrentHashMap <String, DBEntry> table;
	private String name;
	public ModuleEntry(String nm) {
		table = new ConcurrentHashMap<String, DBEntry>();
		name = nm;
	}
	public void add(DBEntry ad) throws EntryExists {
		String theID = ad.getID();
		if(table.containsKey(theID)){
			throw new EntryExists();
		}
		else {
			table.put(theID,ad);
		}
		}
	public boolean isEntry(String key) {
		if(table.containsKey(key)) {
			return true;
		}
		else {
			return false;
		}
	}
	public boolean isEntry(String key, String tag) {
		if(table.containsKey(key)) {
return table.get(key).isTag(tag);
		}
		else {
			return false;
		}
	}
	public boolean isID(String key) {
		return table.containsKey(key);
	}
	public void addLeaf(String ID, String key, String value) throws EntryExists {
		if(isID(ID)) {
			table.get(ID).add(key, value);
		}
		else {
			DBEntry temp = new DBEntry(ID);
			temp.add(key, value);
			add(temp);
		}
	}

}
